package com.fram.controller.api;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fram.bean.api.advertising.request.AdvertisingDisplaySearchRequest;
import com.fram.bean.sys.ResponseMsg;
import com.fram.common.canstant.ErrCode;
import com.fram.common.exception.ProException;
import com.fram.common.util.PublicMethod;
import com.fram.common.util.apiversion.ApiVersion;
import com.fram.service.api.v1.AdvertisingDisplayService;

/**
 * @作者： 陳曉鬆 @时间： 2020年6月1日 - 上午9:33:14 @description：->
 */
@RestController
@RequestMapping("/api/{version}/adver")
public class AdvertisingDisplayController {

	private static Logger LOG = LoggerFactory.getLogger(AdvertisingDisplayController.class);

	@Resource(name = "advertisingDisplayService")
	private AdvertisingDisplayService advertisingDisplayService;

	@ApiVersion(1.0)
	@RequestMapping(value = "/list")
	private ResponseMsg list(@RequestBody AdvertisingDisplaySearchRequest request) throws ProException {
		ResponseMsg msg = ResponseMsg.returnBeanBuild();
		try {
			msg.setData(advertisingDisplayService.list(request));
		} catch (ProException e) {
			LOG.error("-广告-获取广告列表出错->{},{},{}", msg.getSessionId(), e.getErrorCode(), e.getErrorMsg());
			msg.setReturnCode(e.getErrorCode()).setReturnMsg(e.getErrorMsg());
		} catch (Exception e) {
			LOG.error("-广告-获取广告列表异常->{},{}", msg.getSessionId(), PublicMethod.printErrorTrace(e));
			msg.setReturnCode(ErrCode.ERR.getReturnCode()).setReturnMsg(ErrCode.ERR.getReturnMsg());
		}
		return msg;
	}
}
